//引入axios
import request from '@/utils/request';
//引入数据泛型
import type{categoryResponseData} from './model/attr';
//枚举定义接口
enum API {
    //一级分类接口
    C1 = "/admin/product/getCategory1",
    //二级分类接口
    C2 = "/admin/product/getCategory2/",
    //三级分类接口
    C3 = "/admin/product/getCategory3/",
    //获取三级分类下全部商品
    ATTR = "/admin/product/attrInfoList/",
    //修改或添加属性
    ADDUPDATEATTR = '/admin/product/saveAttrInfo',
    //删除属性
    DELETEATTR = "/admin/product/deleteAttr/"
}

//一级分类的请求
export const reqC1List = () => request.get<any,categoryResponseData>(API.C1);
//二级分类的请求
export const reqC2List = (category1Id:number|string) => request.get<any,categoryResponseData>(API.C2+category1Id)
//三级分类的请求
export const reqC3List = (category2Id:number|string) => request.get<any,categoryResponseData>(API.C3+category2Id)
//获取三级分类下面的数据
export const reqAttrList = (category1Id:number|string,category2Id:number|string,category3Id:number|string,) =>request.get<any,categoryResponseData>(API.ATTR+`${category1Id}/${category2Id}/${category3Id}`)
//修改或删除属性
export const reqAddUpdateAttr = (data:any) =>request.post(API.ADDUPDATEATTR,data)
//删除数据
export const reqDeleteAttr = (attrId:number)=>request.delete<any,any>(API.DELETEATTR+attrId);